package com.example.dangdangbackend.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

import java.io.FileWriter;
import java.io.IOException;

public class AlipayConfig {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "9021000138624530";//9021000131627707
    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCCc9X1sx5tEJUANjkswA7amA/wLfS0r2MqSvecmPHTpTD3GHbd3xDKx6/IqM1kV7KfmKIY4FDJ/Mtu8nQYbF6LqhfuL4S3QIiilleJqBaq14vQL82SsLPced9FBgtvcDu+PIxn2XbMsLfSj+o5Ui+YTibvvKpixort2s3xBvP7CJ1LrrwYa+uqpqEsYDSj39sfeq+Md/MORzJB+XYG4Rjl/Grmfqzn9VlR9zsrE4iiyxnyKBSDifCsgK96DOxVNiEibKlelKvsIi2ICUj1LoBZ9cw5V/ptUoLuArp9Cr/a5Kw1Wrf96/uFcfJeMc9xpqePmyORdZcVXiOLEPANQUIFAgMBAAECggEAWrtSXzebu+PCnokYLyXNrwAAZd6wylMKN8o4ejRuTfQhIFtloV+agE9u1bOCV34fgJ1acM7jofkvTRVY5fvJrn45crKeLg62ec7zR40fZufQGJaG9rXsAzbIsWtI3NNE2kWmqjw4QpnO4Ka0E/YzoE0LC8c/AsBwtIpwnmllnH0Qn8f5h27vGrIrAKOcC8hvjG1C/bX65bcHcBVFAMtCbfp3cQw6Fl2c2Fou2fxZUSl4t7UvLkveszMuSIDhWGiDvzw7bCMh2SvycjwWz9Pg4q/eDOICImjkhC/u/OrNfDWAToL2/HXsW59XOxYJhQ59ak8RdVzBwLWdapZMFnWW6QKBgQD5zTcumUyCERkk6VdRKIxUVkY7eUGOLpL9InUsBqBp0/f2iIoXcTB4s+H/8XrAm0p7O0EveUia+K/XcjiRzyVi8YmiE6hEbgYLZQNNW7WBDV9vEvhqWEKIlY68635onKUljFcnj7UJTfN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gAq4fcYsOVEVsO6MphfDW+vqC2h6U85AoGAclkYSSHziHCQj+qoqtq8mNKETjZKyF/CJj86G3J5htkchWaaW5U5JNKyf2x9DSQsmLNEMr3bUnv/OBOUwUXB2Hl7oUIT9DFBbXTA7SQMy7IpMiHA/k/hUpz7wOFIsg8YX20O1RiAehgp9rDRYLelA+4XVurE39HKmqXjO1fgKfM=";*/
    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApT4k1MwnghZNXoCm3z91tgq/Yzez//sKt8kMa+UCM+iJqcvVr9nNkHIQJlmBy8oX13npUq0E700qWBA8uObP3DfBZ0elsiIapTEISvDBV8cTS9w4PjE6CAXBH2KRO+gRhn2NP3v2JUEuGzmKmysXS8UV1iI7vJwIfuQoK8E3l52pxWWL5F1lsKInoI7TIJCWFDIT8Y3y0Hbzvi0Y5WDnnH02t86Qgx7QwQi16X8cLLvG+RqscUjbUJZ6oSFT+r83O76f6GCooc/Ghv6G3Nne/+Gx3cuhEPoXzGwUEK6W8LSzy4m/gnqOc6stTn4sb2APRsdxYLZuzIJdO1sEew31JwIDAQAB";
    /*"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjZX93j5HtMUXWta05SqHQ+/iVnx7WxuDT535QK3+Ko0h2QGsUUyh7N879EBibQH6NWnUcMWXItKLuZQbZjOlA+WhntamitaJ1u5TcMFi4YA10yiotrmSIJjzRbC+XQ6QZxxxD227BnTsvwEzTDY8uWdvJvssGq/ljqovh59ceTMmfTYjzL3Y1PcX+u96Gsi/yLBqY9nqHUyggutqnEqeq2ODipV/c/n3eIxyaLXBu+dbUHH4X8xkSssLrtkf2fsfo7OVTXernUtVZsPNkODnlHqP9l3PUbsrdh0vXPJVUEg0bS4FcxWKF2q52DnkhcucZ1UiKWaHL05pKYxM3DA2+wIDAQAB";*/

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
//	public static String notify_url = "http://localhost:8080/alipay/notify_url.jsp";
    public static String notify_url = "http://localhost:8090/trade/trade/notify";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
//	public static String return_url = "http://localhost:8080/alipay/return_url.jsp";
    public static String return_url = "http://localhost:8090/trade/return";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    // 请求网关地址  真实环境网关：https://openapi.alipay.com/gateway.do
    //	         沙箱环境网关：https://openapi-sandbox.dl.alipaydev.com/gateway.do
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    //获得初始化的AlipayClient
    public static AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
    // 日志记录目录
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
